﻿// -----------------------------------------------------------------------
// <copyright file="MsSqlEmbeddedQueryProducerBase.cs" company="">
// TODO: Update copyright text.
// </copyright>
// -----------------------------------------------------------------------

namespace Dhgms.TplHelper.Model.DataReaderProducer
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Reflection;
    using System.Text;

    /// <summary>
    /// TODO: Update summary.
    /// </summary>
    public abstract class MsSqlEmbeddedQueryProducerBase : MsSqlProducerBase
    {
        private readonly string resourceFilename;

        private readonly string resourceNameSpace;

        private readonly Assembly assembly;

        /// <summary>
        /// 
        /// </summary>
        /// <param name="connectionString"></param>
        /// <param name="assembly"></param>
        /// <param name="resourceNameSpace"></param>
        /// <param name="resourceFilename"></param>
        /// <exception cref="ArgumentNullException"></exception>
        protected MsSqlEmbeddedQueryProducerBase(string connectionString, System.Reflection.Assembly assembly, string resourceNameSpace, string resourceFilename)
            : base(connectionString)
        {
            if (assembly == null)
            {
                throw new ArgumentNullException("assembly");
            }

            if (string.IsNullOrWhiteSpace(resourceNameSpace))
            {
                throw new ArgumentNullException("resourceNameSpace");
            }

            if (string.IsNullOrWhiteSpace(resourceFilename))
            {
                throw new ArgumentNullException("resourceFilename");
            }

            this.assembly = assembly;
            this.resourceNameSpace = resourceNameSpace;
            this.resourceFilename = resourceFilename;
        }

        /// <summary>Gets the SQL command.</summary>
        public sealed override string SqlCommand
        {
            get
            {
                return DataManager.Model.Helper.ReflectionExtensions.LoadStringFromResource(this.assembly, this.resourceNameSpace, this.resourceFilename);
            }
        }
    }
}
